package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IReceiveOrBackEngineeringOrderView;
import com.cloudsigns.factorymanager2.engineering.IView.IReceiveOrBackPublicationOrderView;
import com.cloudsigns.factorymanager2.engineering.model.IReceiveOrBackEngineeringOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.IReceiveOrBackPublicationOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.ReceiveOrBackEngineeringOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.ReceiveOrBackPublicationOrderModel;

/**
 * Created by tony on 2018/5/26.
 */

public class ReceiveOrBackPublicationOrderPresenter {
    private IReceiveOrBackPublicationOrderView view;
    private IReceiveOrBackPublicationOrderModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public ReceiveOrBackPublicationOrderPresenter(IReceiveOrBackPublicationOrderView view) {
        this.view = view;
        this.model = new ReceiveOrBackPublicationOrderModel();
    }

    public void receiveOrBackPublicationOrder() {


        model.receiveOrBackPublicationOrder(view.getOrderId(), view.getStatus(),new ReceiveOrBackPublicationOrderModel.OnReceiveOrBackPublicationOrderListener() {
            @Override
            public void receiveOrderSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.receiveOrBackOrderSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.receiveOrBackOrderFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
